Skip to content

feat(sanic): Support span streaming#6319

Merged
sl0thentr0py merged 3 commits into
masterfrom
neel/span-first/sanic
May 26, 2026
Merged

feat(sanic): Support span streaming#6319
sl0thentr0py merged 3 commits into
masterfrom
neel/span-first/sanic

Conversation

@sl0thentr0py
Copy link
Copy Markdown
Member

@sl0thentr0py sl0thentr0py commented May 21, 2026

The _unsampled_statuses option is not respected for span streaming since we currently don't allow tail-based sampling in the new system.

Issues

@sl0thentr0py sl0thentr0py requested a review from a team as a code owner May 21, 2026 12:56
@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 21, 2026

PY-2357

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 21, 2026

Codecov Results 📊

67 passed | Total: 67 | Pass Rate: 100% | Execution Time: 6.14s

📊 Comparison with Base Branch

Metric Change
Total Tests
Passed Tests
Failed Tests
Skipped Tests

✨ No test changes detected

All tests are passing successfully.

❌ Patch coverage is 9.52%. Project has 14506 uncovered lines.
✅ Project coverage is 35.68%. Comparing base (base) to head (head).

Files with missing lines (1)
File Patch % Lines
sanic.py 9.35% ⚠️ 194 Missing
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    35.03%    35.68%    +0.65%
==========================================
  Files          190       190         —
  Lines        22647     22553       -94
  Branches      7722      8157      +435
==========================================
+ Hits          7934      8047      +113
- Misses       14713     14506      -207
- Partials       718       712        -6

Generated by Codecov Action

@sl0thentr0py sl0thentr0py force-pushed the neel/span-first/sanic branch from d266281 to 950a311 Compare May 21, 2026 13:00
Comment thread tests/integrations/sanic/test_sanic.py
Comment thread sentry_sdk/integrations/sanic.py Outdated
@sl0thentr0py sl0thentr0py force-pushed the neel/span-first/sanic branch 2 times, most recently from ca346f8 to d10461b Compare May 21, 2026 13:27
Comment thread sentry_sdk/integrations/sanic.py Outdated
@sl0thentr0py sl0thentr0py force-pushed the neel/span-first/sanic branch from d10461b to 9e8d40b Compare May 21, 2026 13:48
Comment thread sentry_sdk/traces.py Outdated
@sl0thentr0py sl0thentr0py force-pushed the neel/span-first/sanic branch 2 times, most recently from e9d3bf6 to 0f32453 Compare May 21, 2026 14:16
Copy link
Copy Markdown
Member

@ericapisani ericapisani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some small things but otherwise LGTM. Approving so as not to block it from merging

Comment thread sentry_sdk/integrations/sanic.py Outdated
Comment thread sentry_sdk/integrations/sanic.py
Comment thread tests/integrations/sanic/test_sanic.py Outdated
Comment thread sentry_sdk/integrations/sanic.py Outdated
Copy link
Copy Markdown
Contributor

@sentrivana sentrivana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, couple small things _end -> end and TransactionSource -> SegmentSource

with capture_internal_exceptions():
scope = sentry_sdk.get_current_scope()
route_name = route.name.replace(request.app.name, "").strip(".")
scope.set_transaction_name(route_name, source=TransactionSource.COMPONENT)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a SegmentSource too for the streaming path. Would be good to use that if span streaming is enabled

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well the method itself is called set_transaction_name. If we want to clean this up properly, we should make a segment based method, just switching the source is half-assed

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll merge this for now, let's clean this up separately all together

sanic_route = sanic_route[len(sanic_app_name) + 1 :]

scope.set_transaction_name(
sanic_route, source=TransactionSource.COMPONENT
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here too we should do SegmentSource if streaming

)
else:
scope.set_transaction_name(
rv[0].__name__, source=TransactionSource.COMPONENT
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here

Comment thread tests/integrations/sanic/test_sanic.py Outdated
Comment thread tests/integrations/sanic/test_sanic.py Outdated
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 6748b61. Configure here.

Comment thread sentry_sdk/integrations/sanic.py Outdated
@sl0thentr0py sl0thentr0py force-pushed the neel/span-first/sanic branch from 7e2267f to cb11ab0 Compare May 26, 2026 12:23
The `_unsampled_statuses` option is not respected for span streaming
since we currently don't allow tail-based sampling in the new system.
@sl0thentr0py sl0thentr0py force-pushed the neel/span-first/sanic branch from 0a35b9d to 58850a3 Compare May 26, 2026 13:58
@sl0thentr0py sl0thentr0py enabled auto-merge (squash) May 26, 2026 13:58
@sl0thentr0py sl0thentr0py merged commit fdeb78e into master May 26, 2026
157 checks passed
@sl0thentr0py sl0thentr0py deleted the neel/span-first/sanic branch May 26, 2026 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate sanic to span first

4 participants